import 'package:PollOnLine/manager/UserInfoManager.dart';
import 'package:PollOnLine/ui/my/set/set_view.dart';
import 'package:get/get.dart';

import 'my_state.dart';

class MyLogic extends GetxController {
  final MyState state = MyState();

  @override
  void onReady() {
    super.onReady();
    initData();
  }

  void initData() {
    state.userName = UserInfoManager().getUserName();
    state.district = UserInfoManager().userInfo?.cityInfo ?? '';
    if (state.district.length > 15) {
      state.district = state.district.substring(0, 15);
    }
    state.level = UserInfoManager().userInfo?.uiasRoleList?.first.roleName ?? '';
    update();
  }

  void goToSet() {
    Get.to(() => const SetPage(title: '设置'));
  }

  @override
  void onClose() {
    super.onClose();
  }
}
